# CMake最小支持版本
cmake_minimum_required(VERSION 3.16)
# 工程名，指定版本号以及使用语言
project(hello VERSION 1.0.0 LANGUAGES C CXX)

# ----------------------------------------------------- 系统信息
MESSAGE(STATUS "CMAKE_SYSTEM: ${CMAKE_SYSTEM}")
MESSAGE(STATUS "CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
MESSAGE(STATUS "CMAKE_SYSTEM_VERSION: ${CMAKE_SYSTEM_VERSION}")
MESSAGE(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE(STATUS "CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM}")
MESSAGE(STATUS "CMAKE_HOST_SYSTEM_NAME: ${CMAKE_HOST_SYSTEM_NAME}")
MESSAGE(STATUS "CMAKE_HOST_SYSTEM_VERSION: ${CMAKE_HOST_SYSTEM_VERSION}")

# ----------------------------------------------------- 编译器信息
# 指定C编译器和C++编译器使用版本
set(CMAKE_C_STANDARD ${CMAKE_C_STANDARD})
set(CMAKE_CXX_STANDARD 17)
MESSAGE(STATUS "CMAKE_C_STANDARD: ${CMAKE_C_STANDARD}")
MESSAGE(STATUS "CMAKE_CXX_STANDARD: ${CMAKE_CXX_STANDARD}")

# 设置C编译器
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -std=c99")
# 设置C++编译器
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -std=c++17")
MESSAGE(STATUS "CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
MESSAGE(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")

# 配置编译器类型
#set(CMAKE_BUILD_TYPE Debug)
#set(CMAKE_BUILD_TYPE Release)
MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

# 编译器位置
MESSAGE(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
MESSAGE(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")

# 设置优化等级
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g -O0")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0")
#set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2")
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
MESSAGE(STATUS "CMAKE_C_FLAGS_DEBUG: ${CMAKE_C_FLAGS_DEBUG}")
MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
MESSAGE(STATUS "CMAKE_C_FLAGS_RELEASE: ${CMAKE_C_FLAGS_RELEASE}")
MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}")

# ----------------------------------------------------- 文件操作
MESSAGE(STATUS "CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
MESSAGE(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}")

# 获取指定路径下指定文件
file(GLOB FILES . "*.cc")
MESSAGE(STATUS "FILES: ${FILES}")
# 递归获取
file(GLOB_RECURSE FILES_RECURSE . "*.cc" "*.txt")
MESSAGE(STATUS "FILES_RECURSE: ${FILES_RECURSE}")

# 获取指定路径下的源文件
aux_source_directory(${CMAKE_SOURCE_DIR} SOURCES)
aux_source_directory(${CMAKE_SOURCE_DIR}/libs LIBS_SOURCES)
MESSAGE(STATUS "SOURCES: ${SOURCES}")
MESSAGE(STATUS "LIBS_SOURCES: ${LIBS_SOURCES}")

#add_executable(hello main.cc)
add_executable(hello ${SOURCES} ${LIBS_SOURCES})